<template>
  <div>
    <el-button @click="mth1(10.123456)" type="primary">按钮</el-button>
    <el-button @click="getUserById">根据Id查询用户</el-button>
    <h2>{{ user.username }}</h2>
    <h2>{{ user.password }}</h2>
  </div>
</template>


<script>

export default {
  name: "C2AxiosView",
  data() {
    return {
      user: {
        username: undefined,
        password: undefined,
      },
    }
  },
  methods: {
    mth1: function (val) {
      console.log(this.abc(val));
    },
    getUserById: function () {
      this.axios.get("http://localhost:8888/user/getUserById?id=2")
          .then(res => {
            this.user = res.data.data;
            this.$message({
              type: "success",
              showClose: true,
              message: "查询成功"
            })
          }).catch(err => {
        console.log(err)
      });
    },
  }
}
</script>

<style scoped>

</style>